package kangbo.studentmanagementsystem;

import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;

import java.util.Collections;

public class Student_message  implements Comparable<Student_message> {

    private final SimpleIntegerProperty num;
    private final SimpleStringProperty ID ;
    private final SimpleStringProperty name;
    private final SimpleStringProperty gender;
    private final SimpleStringProperty birthday;
    private final SimpleStringProperty address;
    private final SimpleStringProperty phone;

    public String getID() {
        return ID.get();
    }

    public SimpleStringProperty IDProperty() {
        return ID;
    }

    public void setID(String ID) {
        this.ID.set(ID);
    }

    public String getName() {
        return name.get();
    }

    public SimpleStringProperty nameProperty() {
        return name;
    }

    public void setName(String name) {
        this.name.set(name);
    }

    public String getGender() {
        return this.gender.get();
    }

    public SimpleStringProperty genderProperty() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender.set(gender);
    }

    public String getBirthday() {
        return birthday.get();
    }

    public SimpleStringProperty birthdayProperty() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday.set(birthday);
    }

    public String getAddress() {
        return address.get();
    }

    public SimpleStringProperty addressProperty() {
        return address;
    }

    public void setAddress(String address) {
        this.address.set(address);
    }

    public int getNum() {
        return num.get();
    }

    public SimpleIntegerProperty numProperty() {
        return num;
    }

    public void setNum(int num) {
        this.num.set(num);
    }

    public String getPhone() {
        return phone.get();
    }

    public SimpleStringProperty phoneProperty() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone.set(phone);
    }


    /****************************************************/
    Student_message (String ID ,String name,String gender,String birthday,String address,String phone){
        this.num=new SimpleIntegerProperty(-1);
        this.ID=new SimpleStringProperty(ID);
        this.name= new SimpleStringProperty(name);
        this.gender=new SimpleStringProperty(gender);
        this.birthday=new SimpleStringProperty(birthday);
        this.address=new SimpleStringProperty(address);
        this.phone=new SimpleStringProperty(phone);
    }
    Student_message (int num,String ID ,String name,String gender,String birthday,String address,String phone){
        this.num=new SimpleIntegerProperty(num);
        this.ID=new SimpleStringProperty(ID);
        this.name= new SimpleStringProperty(name);
        this.gender=new SimpleStringProperty(gender);
        this.birthday=new SimpleStringProperty(birthday);
        this.address=new SimpleStringProperty(address);
        this.phone=new SimpleStringProperty(phone);
    }
    Student_message (){
        this.num=new SimpleIntegerProperty(-1);
        this.ID=new SimpleStringProperty("");
        this.name= new SimpleStringProperty("");
        this.gender=new SimpleStringProperty("");
        this.birthday=new SimpleStringProperty("");
        this.address=new SimpleStringProperty("");
        this.phone=new SimpleStringProperty("");
    }
    /**********************************************************/

    /**重写equals方法为学号判重*/
    boolean equals(Student_message student_message){
        return this.getID().equals(student_message.getID());
    }

    public String toString() {
        String s ="";
        return  getID()+","+getName()+","+getGender()+","+getBirthday()+","+getAddress()+","+getPhone();
    }
    public  void setMessage(String s){
        String a[]= s.split(",");
        setID(a[0]);
        setName(a[1]);
//        System.out.println(a[2]);
        setGender(a[2]);
        setBirthday(a[3]);
        setAddress(a[4]);
        setPhone(a[5]);
//        Collections.sort(perole);
    }


    /**学号排序*/
    @Override
    public int compareTo(Student_message o) {
        return this.getID().compareTo(o.getID());
    }

    /***/

}